package com.ssm.basis.model.pojo.domain;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;

import java.io.Serializable;
import java.time.LocalDateTime;

@Getter
@Setter
// @MappedSuperclass
public class BaseDo<T extends Model<?>> extends Model<T> implements Serializable {
    private static final long serialVersionUID = -1695850022460957581L;

    @CreatedBy
    @Schema(description = "创建者")
    @TableField(fill = FieldFill.INSERT)
    String createUser;

    @CreatedDate
    @Schema(description = "创建时间")
    @TableField(fill = FieldFill.INSERT)
    LocalDateTime createTime;

    @LastModifiedBy
    @Schema(description = "更新者")
    @TableField(fill = FieldFill.UPDATE)
    String updateUser;

    /**
     * https://blog.csdn.net/f641385712/article/details/84032022
     */
    @LastModifiedDate
    @Schema(description = "更新时间")
    @TableField(fill = FieldFill.UPDATE)
    LocalDateTime updateTime;

    @TableLogic(value = "0", delval = "1")
    @Schema(description = "是否删除，0：(否)未删除，1：(是)已删除")
    Boolean isDeleted;
}
